package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author stone
 * @date 2022/04/29 16:01
 */
@Controller
public class HelloController {

    @RequestMapping("hello")
    public ModelAndView hello() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/hello.jsp");
        modelAndView.addObject("name", "songge");
        return modelAndView;
    }
    @RequestMapping("hello2")
    public String hello2(Model model) {//Model可以直接写在Handler方法的形参中
        model.addAttribute("name", "ligenli");
        return "/hello.jsp";//返回值字符串作为ModelAndView中的视图名
    }
}
